unit add_prepod_unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, ImgList, StdCtrls, data_module,
  Mask, DBCtrls;

type
  Tadd_prepod_form = class(TForm)
    Label1: TLabel;
    surname_edit: TEdit;
    name_edit: TEdit;
    fathername_edit: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    ok_button: TButton;
    cancek_button: TButton;
    ImageList1: TImageList;
    DBEdit1: TDBEdit;
    DBEdit2: TDBEdit;
    procedure set_edits(fio:string);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  add_prepod_form: Tadd_prepod_form;

implementation

{$R *.dfm}

procedure Tadd_prepod_form.FormShow(Sender: TObject);
begin
  surname_edit.SetFocus;
end;

procedure Tadd_prepod_form.set_edits(fio: string);
var
  i,a,b: Integer;
begin
  a:=0;
  b:=0;
  i:=0;
  repeat
    inc(i);
    if (fio[i]=' ') and (a<>0) then b:=i;
    if (fio[i]=' ') and (a=0)  then a:=i;
  until (a<>0) and (b<>0);
  surname_edit.Text:=copy(fio,1,a-1);
  name_edit.Text:=copy(fio,a+1,b-a-1);
  fathername_edit.Text:=copy(fio,b+1,Length(fio)-b);
end;

end.
